package com.meitianhui.convenitenbuy.util;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Parcelable;

import com.meitianhui.convenitenbuy.Constants;
import com.meitianhui.convenitenbuy.config.InfoProvider;
import com.meitianhui.convenitenbuy.hyphenate.ui.ChatActivity;
import com.meitianhui.convenitenbuy.main.ui.LoginActivity;

/**
 * t页面跳转工具类
 */
public class JumpUtil {


    /**
     * 返回键文字资源ID
     */
    public static final String GO_BACK_ID = "GO_BACK_ID";
    /**
     * 跳转到的值
     */
    public static final String INTENT_VALUE = "INTENT_VALUE";

    /**
     * activity启动来源
     */
    public static final String INTENT_FLAG_SOURCE = "INTENT_FLAG_SOURCE";

    public static final String JUMP_WALLET_FRAGMENT_TYPE = "Jump_Wallet_Fragment_type";
    public static final String JUMP_WALLET_FRAGMENT_VALUE = "Jump_Wallet_Fragment_value";
    public static final String JUMP_USER_PHONE_NUMBER = "userPhoneNumber";
    public static final String JUMP_ADDRESS_CHANGE = "address_change";




    public static Intent getBaseIntent(int goBackId, Context act, Class cls)
    {
        Intent intent = new Intent(act, cls);
        intent.putExtra(INTENT_FLAG_SOURCE, true);
        intent.putExtra(GO_BACK_ID, goBackId);
        return intent;
    }

    /**
     * 跳转到登录activity
     * @param goBackId
     * @param context
     */
    public static void jumpToLoginActivity(int goBackId, Activity context, int requestCode, String strCurrent)
    {
        Intent intent = getBaseIntent(0,context,LoginActivity.class);
        intent.putExtra(JumpUtil.INTENT_VALUE,strCurrent);
        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        context.startActivityForResult(intent,requestCode);
    }

    /**
     * 跳转到WalletActivity
     * @param context
     * @param o 需要传达的Parcelable对象
     */
    public static void jumpToWalletActivity(Activity context, Class clz, Parcelable o) {
        Intent intent = getBaseIntent(0, context, clz);
        intent.putExtra(JUMP_WALLET_FRAGMENT_VALUE, o);
        context.startActivity(intent);
    }

    /**
     * 跳转
     * @param context
     * @param ActivityClass
     */
    public static void  jumpToActivityWithPhoneNumber(Context context, Class ActivityClass){
        Intent intent = new Intent(context, ActivityClass);
        intent.putExtra(JUMP_USER_PHONE_NUMBER, InfoProvider.getUserInfo(context).getMobile());
        context.startActivity(intent);
    }

    public static void jumpToChatActivity(Context context){
        Intent intent = new Intent(context, ChatActivity.class);
        intent.putExtra("userId", Constants.HYPHENATE_ID_EDINBURGH);
        intent.putExtra("chatType", Constants.CHATTYPE_SINGLE);
        intent.putExtra("groupName", Constants.HYPHENATE_TITLE);
        context.startActivity(intent);
    }

    public static void jumpToChatActivity(Context context,String userId){
        Intent intent = new Intent(context, ChatActivity.class);
        intent.putExtra("userId", userId);
        intent.putExtra("chatType", Constants.CHATTYPE_SINGLE);
        intent.putExtra("groupName", Constants.HYPHENATE_TITLE);
        context.startActivity(intent);
    }


}
